#include "CppSQLite3.h"
#include <iostream>

using namespace std;

const char* dbFilename = "blarp.sqlite";

CppSQLite3DB database;
CppSQLite3Query query;

int main(int argc, char** argv)
{
        int i, fld;

		database.open(dbFilename);

        ////////////////////////////////////////////////////////////////////////////////
        // Query data and also show results of inserts into auto-increment field
        ////////////////////////////////////////////////////////////////////////////////
		
        query = database.execQuery("select * from bleat;");
				
		// loop for however many rows 
        while (!query.eof()){

			// How many columns are in the result?
			for (fld = 0; fld < query.numFields(); fld++){

				cout << query.fieldName(fld) << "(" << query.fieldDeclType(fld) << ")";
				cout << "\t> " << query.fieldValue(fld) << endl;
			}	
			
			cout << endl;

			query.nextRow();
		}
		
        cout << endl;

    ////////////////////////////////////////////////////////////////////////////////
    // Loop until user enters q or Q
    ////////////////////////////////////////////////////////////////////////////////
    char c(' ');

    while (c != 'q' && c != 'Q')
    {
        cout << "Press q then enter to quit: ";
        cin >> c;
    }
    return 0;
}

